#include "oscillator.h"
#include <cmath>

Oscillator::Oscillator(QObject *parent) :
        QObject(parent),
        freq(440.),
        curPhase(0.),
        vol(1.)
{
}

void Oscillator::process(){
    float delta = gl::k_pi_x_2 * freq / gl::k_default_samplerate;
    for (int i = 0; i< data_->size; ++i){
        curPhase += delta;
        data_->outputs[0][i] = vol * sin(curPhase);
    }
    curPhase = fmod(curPhase, gl::k_pi_x_2);
}
